# -*- codeing = utf-8 -*-
# !/usr/bin/env python
# @coding  : utf-8
# @File    : 01Graphviz.py
# @Time    : 2022/4/18 10:25
# @Author  : xdd
# @Software: PyCharm
# @desc :$测试Graphviz安装
from sklearn.datasets import load_iris
from sklearn import tree
import pydotplus

iris = load_iris()
print(iris)
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)

dot_data = tree.export_graphviz(clf, out_file=None,
                                feature_names=iris.feature_names,
                                class_names=iris.target_names,
                                filled=True, rounded=True,
                                special_characters=True)

graph = pydotplus.graph_from_dot_data(dot_data)
# graph.write_pdf('iris.pdf')